package com.lujieni.aviator.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * Aviator表达式配置类
 */
@Configuration
@ConfigurationProperties(prefix = "aviator")
public class AviatorConfig {

    private Map<String, String> expressions = new HashMap<>();

    public Map<String, String> getExpressions() {
        return expressions;
    }

    public void setExpressions(Map<String, String> expressions) {
        this.expressions = expressions;
    }

    /**
     * 获取指定名称的表达式
     */
    public String getExpression(String name) {
        return expressions.get(name);
    }

    /**
     * 获取默认表达式
     */
    public String getDefaultExpression() {
        return expressions.getOrDefault("default", "name == 'lujieni' && age > 30");
    }
}
